﻿@using System.Data;
@using System.Web;
@using DTcms.Web.MVC.Areas.Web.Controllers;
@using DTcms.Web.MVC.UI.Controllers;
@{
   Layout = "~/Areas/Web/Views/" + ViewBag.TemplateSkin + "/Shared/_LayoutList.cshtml";
   DTcms.Model.sites site = ViewData["site"] as DTcms.Model.sites;
   DTcms.Model.sysconfig config = ViewData["sysConfig"] as DTcms.Model.sysconfig;
   BaseController bc = ViewBag.BasePage as BaseController;
   SearchController c = ViewBag.This as SearchController;
   ViewBag.Title = "站内搜索 - " + site.name;
   int totalcount;
   int page = int.Parse(ViewBag.Page as string);
   string channel = ViewBag.Channel as string;
   string keyword = ViewBag.Keyword as string;
   string tags = ViewBag.Tags as string;
   string pagelist = string.Empty;
   DataTable tagsList = bc.get_article_tags(0, "is_red=1");//热门标签
   DataTable redNews = bc.get_article_list("news", 0, 4, "status=0 and is_red=1 and img_url<>''");//推荐资讯
   DataTable list=c.get_search_list(15, out totalcount);//取得分页页码列表
   if(tags!=""){
      pagelist = bc.get_page_link(15, page, totalcount, bc.linkurl("search","?tags=" + bc.Server.UrlEncode(tags) + "&page=__id__"));
   }else{
      pagelist = bc.get_page_link(15, page, totalcount, bc.linkurl("search", "?keyword=" + bc.Server.UrlEncode(keyword) + "&page=__id__"));
   } 
 }

<div class="section clearfix">
  <!--右边-->
  <div class="list-right">
    <div class="sidebar-box">
      <div class="line30"></div>
      <h3>热门标签</h3>
      <div class="tags-box">
        @foreach(DataRow dr in tagsList.Rows){
          <a href="@bc.linkurl("search","?tags="+bc.Server.UrlEncode(dr["title"].ToString()))">@dr["title"]<i>(@dr["count"])</i></a>
        }
      </div>
      
      <div class="line20"></div>
      <h3>推荐资讯</h3>
      <div class="focus-list">
        <ul>
          @foreach(DataRow dr in redNews.Rows){
          <li>
            <a title="@dr["title"]" href="@bc.linkurl("news_show",dr["id"])">
              <b><img src="@dr["img_url"]" /></b>
              <span>@dr["title"]</span>
            </a>
          </li>
          }
        </ul>
      </div>
      
    </div>
  </div>
  <!--/右边-->
  
  <!--左边-->
  <div class="list-auto">
      <div class="ntitle">
      <h2><a>站内搜索</a></h2>
      @if(tags!=""){
        <i>查询Tags标签： <b class="blue">@tags</b> ，共有 <b class="red">@totalcount</b> 条记录</i>
      }else{
        <i>搜索关健字： <b class="blue">@keyword</b> ，共有 <b class="red">@totalcount</b> 条记录</i>
      }
    </div>
    <ul class="n-list">
      @foreach(DataRow dr in list.Rows){
      <li>
        <h2><a target="_blank" href="@dr["link_url"]">@dr["title"]</a></h2>
        <div class="note">
          @if(dr["img_url"].ToString() != ""){
          <b><img src="@dr["img_url"]" /></b>
          }
          <p>@dr["remark"]</p>
          <div class="info">
            <span class="time">@dr["add_time"]</span>
            <span class="comm"><script type="text/javascript" src="@(config.webpath)tools/submit_ajax.ashx?action=view_comment_count&channel_id=@dr["channel_id"]&id=@dr["id"]"></script>人评论</span>
            <span class="view"><script type="text/javascript" src="@(config.webpath)tools/submit_ajax.ashx?action=view_article_click&channel_id=@dr["channel_id"]&id=@dr["id"]"></script>次浏览</span>
          </div>
        </div>
      </li>
      }
      @if(totalcount == 0){
      <div class="nodata">很抱歉，目前尚未查找到符合条件的信息！</div>
      }
    </ul>
    
    <!--页码列表-->
    <div class="page-box">
      <div class="digg">@Html.Raw(pagelist)</div>
    </div>
    <!--/页码列表-->
  </div>
  <!--/左边-->
</div>